<template>
  <div class="max-w-6xl mx-auto p-6">
    <!-- <h1 class="text-3xl font-bold text-gray-800 mb-6">第2章 - 开发环境搭建</h1> -->
    
    <!-- 导航栏 -->
    <div class="bg-white rounded-lg shadow-lg mb-6">
      <nav class="flex flex-wrap border-b border-gray-200 overflow-x-auto">
        <button 
          v-for="tab in tabs" 
          :key="tab.id"
          @click="activeTab = tab.id"
          :class="[
            'flex-1 min-w-0 py-3 px-2 sm:py-4 sm:px-4 md:px-6 text-center font-medium transition-colors duration-200 text-sm sm:text-base whitespace-nowrap',
            activeTab === tab.id 
              ? 'text-blue-600 border-b-2 border-blue-600 bg-blue-50' 
              : 'text-gray-600 hover:text-gray-800 hover:bg-gray-50'
          ]"
        >
          <span class="block sm:hidden">{{ tab.name.length > 4 ? tab.name.substring(0, 4) + '...' : tab.name }}</span>
          <span class="hidden sm:block">{{ tab.name }}</span>
        </button>
      </nav>
    </div>
    
    <!-- Tab内容 -->
    <div>
          <!-- 课件资料 Tab -->
          <div v-if="activeTab === 'materials'">
            <MaterialsTab 
              :chapterPath="'/chap02/materials'"
              :materials="chapter2Materials"
              :showChapterHighlights="true"
              :chapterNumber="2"
            />
          </div>

          <!-- 视频内容 Tab -->
          <VideosTab 
            v-if="activeTab === 'videos'" 
            :title="'第二章 - 前端开发环境搭建'"
            :mainVideos="chapter2MainVideos"
            :videoList="chapter2VideoList"
          />

          <!-- 示例内容 Tab -->
          <ExamplesGrid 
            v-if="activeTab === 'examples'" 
            :examples="chapter2Examples"
            chapterName="chapter2-examples"
          />

          <!-- 作业与任务 Tab -->
          <div v-if="activeTab === 'assignments'" class="bg-white rounded-lg shadow-lg p-6">
            <h2 class="text-2xl font-bold text-gray-800 mb-4">作业与任务</h2>
            <div class="space-y-4">
              <div class="border border-gray-200 rounded-lg p-4">
                <h3 class="text-lg font-semibold text-gray-800 mb-2">环境搭建实践</h3>
                <p class="text-gray-600 mb-3">按照课程指导完成开发环境的搭建</p>
                <div class="flex items-center justify-between">
                  <span class="text-sm text-gray-500">截止时间：课程结束后一周</span>
                  <button class="px-4 py-2 bg-green-500 hover:bg-green-600 text-white rounded-md transition-colors">
                    开始任务
                  </button>
                </div>
              </div>
            </div>
          </div>

          <!-- 扩展资源 Tab -->
          <div v-if="activeTab === 'grading'">
            <ExtensionsTab 
              title="第2章 - 开发环境搭建扩展资源" 
              :materials="chapter2ExtensionMaterials"
              :recommendedResources="chapter2RecommendedResources"
            />
          </div>
        </div>

    <!-- PDF 预览区域 -->
    <div v-if="isPdfViewerVisible" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
      <div class="bg-white rounded-lg shadow-xl w-11/12 h-5/6 flex flex-col">
        <div class="flex items-center justify-between p-4 border-b border-gray-200">
          <h3 class="text-lg font-semibold text-gray-800">PDF 预览</h3>
          <button @click="hidePdfViewer" class="text-gray-500 hover:text-gray-700">
            <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
              <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
            </svg>
          </button>
        </div>
        <div class="flex-1 p-4">
          <iframe 
            :src="currentPdfPath" 
            class="w-full h-[600px] border border-gray-300 rounded"
            frameborder="0"
          ></iframe>
        </div>
      </div>
    </div>

    <!-- DOCX 预览区域 -->
    <div v-if="isDocxViewerVisible" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
      <div class="bg-white rounded-lg shadow-xl w-11/12 h-5/6 flex flex-col">
        <div class="flex items-center justify-between p-4 border-b border-gray-200">
          <h3 class="text-lg font-semibold text-gray-800">DOCX 预览</h3>
          <div class="flex items-center space-x-2">
            <button 
              @click="downloadDocx(currentDocxPath)"
              class="px-3 py-1 bg-blue-500 hover:bg-blue-600 text-white rounded text-sm transition-colors"
            >
              下载
            </button>
            <button @click="hideDocxViewer" class="text-gray-500 hover:text-gray-700">
              <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
              </svg>
            </button>
          </div>
        </div>
        <div class="flex-1 p-4 overflow-y-auto" id="docx-viewer-content">
          <div v-if="isLoadingDocxViewer" class="flex items-center justify-center h-full">
            <div class="text-center">
              <div class="inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"></div>
              <p class="mt-2 text-gray-600">加载中...</p>
            </div>
          </div>
          <div v-else-if="docxViewerError" class="flex items-center justify-center h-full">
            <div class="text-center">
              <p class="text-red-600">{{ docxViewerError }}</p>
            </div>
          </div>
          <div v-else class="prose max-w-none" v-html="docxViewerContent"></div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { marked } from 'marked'
import MaterialsTab from '@/components/MaterialsTab.vue'
import VideosTab from '@/components/VideosTab.vue'
import ExtensionsTab from '@/components/ExtensionsTab.vue'
import ExamplesGrid from '@/components/ExamplesGrid.vue'

interface MarkdownFile {
  name: string
  title: string
  description: string
  type: string
  path: string
}

interface OutlineItem {
  id: string
  text: string
  level: number
}

// Tab 相关
const activeTab = ref('materials')
const tabs = [
  { id: 'materials', name: '课件资料' },
  { id: 'videos', name: '视频内容' },
  { id: 'examples', name: '示例内容' },
  { id: 'assignments', name: '作业与任务' },
  { id: 'grading', name: '扩展资源' }
]

// 目录相关
const isOutlineExpanded = ref(true)
const documentOutline = ref<OutlineItem[]>([])

// PDF 预览相关
const isPdfViewerVisible = ref(false)
const currentPdfPath = ref('')

// DOCX 预览相关
const isDocxViewerVisible = ref(false)
const currentDocxPath = ref('')
const docxViewerContent = ref('')
const isLoadingDocxViewer = ref(false)
const docxViewerError = ref('')

// Markdown 相关
const selectedFile = ref<MarkdownFile | null>(null)
const markdownContent = ref('')
const loading = ref(false)
const error = ref('')

// 第2章材料配置
const chapter2Materials = ref([
  {
    type: 'pdf',
    title: 'PDF 课件 (第一部分)',
    description: '第2章-开发环境搭建 第一部分',
    icon: 'red',
    files: ['/第02.1课 第2章-开发环境搭建.pdf']
  },
  {
    type: 'pdf',
    title: 'PDF 课件 (第二部分)',
    description: '第2章-开发环境搭建 第二部分',
    icon: 'blue',
    files: ['/第02.2课 第2章-开发环境搭建.pdf']
  },
  {
    type: 'docx',
    title: 'DOCX 文档',
    description: '第2章-开发环境的搭建 详细文档',
    icon: 'green',
    files: ['/第2章-开发环境的搭建.docx']
  }
])

const markdownFiles = ref<MarkdownFile[]>([
  {
    name: 'build_env.md',
    title: '前端开发环境搭建指南(简化版本)',
    description: 'Windows系统下的完整前端开发环境配置教程',
    type: '综合',
    path: '/chap02/build_env.md'
  },
  {
    name: 'Guide.md',
    title: '前端开发环境搭建指南',
    description: 'Windows系统下的完整前端开发环境配置教程',
    type: 'Windows',
    path: '/chap02/Guide.md'
  },
  {
    name: 'Guide4Mac.md',
    title: '前端开发环境搭建指南 (macOS版)',
    description: 'macOS系统下的完整前端开发环境配置教程',
    type: 'macOS',
    path: '/chap02/Guide4Mac.md'
  }
])

// 扩展链接数据
const extensionLinks = ref([
  'https://www.runoob.com/git/git-install-setup.html',
  'https://gitee.com',
  'https://www.runoob.com/nodejs/nodejs-install-setup.html'
])

// 将传入的链接转换为材料数据
const convertLinksToMaterials = (links:any) => {
  const linkMaterials = links.map((link:any, index:any) => {
    let title = ''
    let description = ''
    let type = 'reference'
    let category = 'reference'
    let tags = []
    
    if (link.includes('git')) {
      if (link.includes('gitee.com')) {
        title = 'Gitee - 代码托管平台'
        description = 'Gitee是开源中国推出的代码托管平台，支持Git和SVN，提供免费的私有仓库。'
        type = 'tool'
        category = 'tool'
        tags = ['Git', '代码托管', '版本控制']
      } else {
        title = 'Git 安装配置教程'
        description = 'Git版本控制系统的安装和配置指南，包含Windows、Linux、Mac等平台的详细安装步骤。'
        type = 'tutorial'
        category = 'tutorial'
        tags = ['Git', '版本控制', '安装教程']
      }
    } else if (link.includes('nodejs')) {
      title = 'Node.js 安装配置教程'
      description = 'Node.js运行环境的安装和配置指南，包含各平台的安装方法和环境配置。'
      type = 'tutorial'
      category = 'tutorial'
      tags = ['Node.js', 'JavaScript', '环境搭建']
    } else {
      title = `扩展资源 ${index + 1}`
      description = '相关的扩展学习资源'
      type = 'reference'
      category = 'reference'
      tags = ['扩展资源']
    }
    
    return {
      id: `link-${index + 1}`,
      title,
      description,
      url: link,
      type,
      category,
      tags,
      author: '菜鸟教程',
      publishDate: '2024-01-01',
      readTime: '15分钟',
      difficulty: '初级',
      isFavorite: false
    }
  })
  
  return linkMaterials
}

// 第2章扩展材料数据
const chapter2ExtensionMaterials = ref([
  ...convertLinksToMaterials(extensionLinks.value)
])

// 第2章推荐资源数据
const chapter2RecommendedResources = ref([
  {
    id: 1,
    title: 'Gitee代码托管平台',
    description: '国内优秀的Git代码托管平台，支持私有仓库和团队协作',
    url: 'https://gitee.com/'
  },
  {
    id: 2,
    title: 'npm官方包管理器',
    description: 'Node.js的官方包管理器，管理项目依赖和发布包',
    url: 'https://www.npmjs.com/'
  },
  {
    id: 3,
    title: 'Yarn包管理器',
    description: 'Facebook开发的快速、可靠、安全的依赖管理工具',
    url: 'https://yarnpkg.com/'
  },
  {
    id: 4,
    title: 'Vite构建工具',
    description: '下一代前端构建工具，提供极速的开发体验',
    url: 'https://vitejs.dev/'
  }
])

// 第2章视频数据
const chapter2MainVideos = ref([
  {
    id: 'chap2-main1',
    title: '前端开发环境搭建',
    url: '/chap02/videos/2.1前端开发环境.mp4',
    description: '第2章主要内容：前端开发环境的搭建与配置'
  },
  {
    id: 'chap2-main2',
    title: '前端开发环境搭建指南',
    url: '/chap02/videos/2.2前端开发环境搭建指南.mp4',
    description: '详细的前端开发环境搭建指南和最佳实践'
  },
  {
    id: 'chap2-main3',
    title: 'VSCode基本使用',
    description: 'VSCode编辑器的基本使用方法和技巧',
    duration: '20:30',
    views: '1.6k',
    url: '/chap02/videos/2.3VSCode基本使用.mp4'
  }
])

const chapter2VideoList = ref([
  {
    id: 'chap2-1',
    title: '开发环境搭建概述',
    description: '介绍前端开发环境的基本概念和重要性',
    duration: '12:30',
    views: '1.5k',
    url: '/chap02/videos/2.1前端开发环境.mp4'
  },
  {
    id: 'chap2-4',
    title: 'VSCode基本使用',
    description: 'VSCode编辑器的基本使用方法和技巧',
    duration: '20:30',
    views: '1.6k',
    url: '/chap02/videos/2.3VSCode基本使用.mp4'
  }
])

// 第2章示例数据
const chapter2Examples = ref([
  {
    id: '1',
    title: '前端开发环境介绍',
    description: '介绍前端开发环境的基本概念、组成部分和重要性',
    type: '前端开发环境',
    difficulty: 'easy' as const,
    fileName: '2.1.html',
    filePath: '/chap02/2.1.html'
  }
])

// 目录相关函数
const toggleOutline = () => {
  isOutlineExpanded.value = !isOutlineExpanded.value
}

const generateDocumentOutline = () => {
  const content = document.getElementById('docx-viewer-content')
  if (!content) return

  const headings = content.querySelectorAll('h1, h2, h3, h4, h5, h6')
  const outline: OutlineItem[] = []

  headings.forEach((heading, index) => {
    const level = parseInt(heading.tagName.charAt(1))
    const text = heading.textContent || ''
    const id = `heading-${index}`
    heading.id = id
    
    outline.push({ id, text, level })
  })

  documentOutline.value = outline
}

const scrollToHeading = (headingId: string) => {
  const element = document.getElementById(headingId)
  if (element) {
    element.scrollIntoView({ behavior: 'smooth' })
  }
}

// PDF 相关函数
const showPdfViewer = (pdfPath: string) => {
  currentPdfPath.value = pdfPath
  isPdfViewerVisible.value = true
}

const hidePdfViewer = () => {
  isPdfViewerVisible.value = false
  currentPdfPath.value = ''
}

// DOCX 相关函数
const showDocxViewer = async (docxPath: string) => {
  currentDocxPath.value = docxPath
  isDocxViewerVisible.value = true
  isLoadingDocxViewer.value = true
  docxViewerError.value = ''
  
  try {
    const response = await fetch(docxPath)
    if (!response.ok) {
      throw new Error(`HTTP error! status: ${response.status}`)
    }
    
    // 简单的DOCX预览，实际项目中可能需要使用mammoth.js等库
    docxViewerContent.value = '<p>DOCX文件预览功能需要额外的库支持，请下载文件查看完整内容。</p>'
    
    // 生成目录
    setTimeout(() => {
      generateDocumentOutline()
    }, 100)
  } catch (err) {
    console.error('Error loading DOCX file:', err)
    docxViewerError.value = '加载 DOCX 文件失败，请检查文件路径是否正确'
  } finally {
    isLoadingDocxViewer.value = false
  }
}

const hideDocxViewer = () => {
  isDocxViewerVisible.value = false
  currentDocxPath.value = ''
  docxViewerContent.value = ''
  documentOutline.value = []
}

const downloadDocx = (docxPath: string) => {
  const link = document.createElement('a')
  link.href = docxPath
  link.download = docxPath.split('/').pop() || 'document.docx'
  document.body.appendChild(link)
  link.click()
  document.body.removeChild(link)
}

// Markdown 相关函数
const selectFile = async (file: MarkdownFile) => {
  selectedFile.value = file
  await loadMarkdownContent(file.path)
}

const loadMarkdownContent = async (filePath: string) => {
  loading.value = true
  error.value = ''
  
  try {
    const response = await fetch(filePath)
    if (!response.ok) {
      throw new Error(`HTTP error! status: ${response.status}`)
    }
    const text = await response.text()
    markdownContent.value = await marked(text)
  } catch (err) {
    error.value = `加载文件失败: ${err instanceof Error ? err.message : '未知错误'}`
    console.error('Error loading markdown:', err)
  } finally {
    loading.value = false
  }
}

const goBack = () => {
  selectedFile.value = null
  markdownContent.value = ''
  error.value = ''
}

onMounted(() => {
  // 组件挂载时的初始化逻辑
})
</script>

<style scoped>
/* 自定义样式 */
.video-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
}

.video-container video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0.5rem;
}

.prose {
  color: #1f2937;
  line-height: 1.75;
  font-size: 1rem;
}

/* DOCX 预览区域内的标题样式 */
:deep(#docx-viewer-content h1) {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1f2937;
  margin-top: 1.5rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e5e7eb;
}

:deep(#docx-viewer-content h2) {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1f2937;
  margin-top: 1.25rem;
  margin-bottom: 0.75rem;
}

:deep(#docx-viewer-content h3) {
  font-size: 1.125rem;
  font-weight: 600;
  color: #1f2937;
  margin-top: 1rem;
  margin-bottom: 0.75rem;
}

:deep(#docx-viewer-content h4) {
  font-size: 1rem;
  font-weight: 600;
  color: #1f2937;
  margin-top: 0.75rem;
  margin-bottom: 0.5rem;
}

:deep(#docx-viewer-content h5) {
  font-size: 0.875rem;
  font-weight: 600;
  color: #1f2937;
  margin-top: 0.75rem;
  margin-bottom: 0.5rem;
}

:deep(#docx-viewer-content h6) {
  font-size: 0.75rem;
  font-weight: 600;
  color: #1f2937;
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

/* DOCX 预览区域内的表格样式 */
:deep(#docx-viewer-content table) {
  border-collapse: collapse;
  border: 1px solid #9ca3af;
  width: 100%;
  margin: 1rem 0;
}

:deep(#docx-viewer-content th) {
  border: 1px solid #9ca3af;
  padding: 0.75rem;
  text-align: left;
  background-color: #f3f4f6;
  font-weight: 600;
}

:deep(#docx-viewer-content td) {
  border: 1px solid #9ca3af;
  padding: 0.75rem;
}

/* 标题样式优化 - 使用更高特异性覆盖Tailwind base样式 */
.prose :is(h1, h2, h3, h4, h5, h6) {
  font-weight: bold !important;
  line-height: 1.2 !important;
  color: inherit !important;
}

.prose h1 {
  font-size: 2.25rem !important;
  font-weight: 700 !important;
  margin-bottom: 2rem !important;
  margin-top: 1.5rem !important;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
  background-clip: text !important;
  border-bottom: 3px solid #667eea !important;
  padding-bottom: 0.5rem !important;
  display: block !important;
}

.prose h2 {
  font-size: 1.875rem !important;
  font-weight: 700 !important;
  margin-bottom: 1.5rem !important;
  margin-top: 2.5rem !important;
  color: #2563eb !important;
  position: relative !important;
  padding-left: 1rem !important;
  display: block !important;
}

.prose h2::before {
  content: '' !important;
  position: absolute !important;
  left: 0 !important;
  top: 0 !important;
  bottom: 0 !important;
  width: 4px !important;
  background: linear-gradient(to bottom, #3b82f6, #1d4ed8) !important;
  border-radius: 2px !important;
}

.prose h3 {
  font-size: 1.5rem !important;
  font-weight: 600 !important;
  margin-bottom: 1rem !important;
  margin-top: 2rem !important;
  color: #1e40af !important;
  border-left: 4px solid #60a5fa !important;
  padding-left: 1rem !important;
  background: linear-gradient(90deg, #eff6ff 0%, transparent 100%) !important;
  padding-top: 0.5rem !important;
  padding-bottom: 0.5rem !important;
  display: block !important;
}

.prose h4 {
  font-size: 1.25rem !important;
  font-weight: 600 !important;
  margin-bottom: 0.75rem !important;
  margin-top: 1.5rem !important;
  color: #1e3a8a !important;
  position: relative !important;
  display: block !important;
}

.prose h4::before {
  content: '▶' !important;
  color: #3b82f6 !important;
  margin-right: 0.5rem !important;
  font-size: 0.8em !important;
}

.prose h5 {
  font-size: 1.125rem !important;
  font-weight: 600 !important;
  margin-bottom: 0.5rem !important;
  margin-top: 1rem !important;
  color: #1e40af !important;
  display: block !important;
}

.prose h6 {
  font-size: 1rem !important;
  font-weight: 600 !important;
  margin-bottom: 0.5rem !important;
  margin-top: 0.75rem !important;
  color: #2563eb !important;
  display: block !important;
}

/* 段落和文本样式 */
.prose p {
  margin-bottom: 1.5rem;
  line-height: 1.75;
  text-align: justify;
}

.prose strong {
  font-weight: 700;
  color: #1e40af;
}

.prose em {
  font-style: italic;
  color: #4338ca;
}

/* 列表样式优化 */
.prose ul {
  margin-bottom: 1.5rem;
  padding-left: 1.5rem;
}

.prose ol {
  margin-bottom: 1.5rem;
  padding-left: 1.5rem;
}

.prose li {
  margin-bottom: 0.75rem;
  line-height: 1.75;
  position: relative;
}

.prose ul li::marker {
  color: #3b82f6;
  font-size: 1.2em;
}

.prose ol li::marker {
  color: #3b82f6;
  font-weight: bold;
}

/* 代码样式优化 */
.prose code {
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.875rem;
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Consolas, 'Liberation Mono', Menlo, monospace;
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  color: #dc2626;
  border: 1px solid #cbd5e1;
  font-weight: 600;
}

.prose pre {
  padding: 1.5rem;
  border-radius: 0.75rem;
  overflow-x: auto;
  margin-bottom: 1.5rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border: 1px solid #334155;
}

.prose pre code {
  background: transparent;
  padding: 0;
  border: 0;
  color: #10b981;
  font-weight: normal;
}

/* 引用样式优化 */
.prose blockquote {
  margin-bottom: 1.5rem;
  padding: 1rem;
  border-top-right-radius: 0.5rem;
  border-bottom-right-radius: 0.5rem;
  border-left: 6px solid #3b82f6;
  background: linear-gradient(90deg, #eff6ff 0%, #f8fafc 100%);
  font-style: italic;
  color: #1e40af;
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.1);
}

.prose blockquote p {
  margin-bottom: 0.5rem;
}

/* 表格样式优化 */
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  border-radius: 0.5rem;
  overflow: hidden;
  border: 1px solid #e5e7eb;
}

.prose th {
  padding: 1rem 1.5rem;
  font-weight: 700;
  color: white;
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  border-bottom: 2px solid #1e40af;
}

.prose td {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #e5e7eb;
  transition: background-color 0.2s ease;
}

.prose tr:nth-child(even) td {
  background-color: #f8fafc;
}

.prose tr:hover td {
  background-color: #eff6ff;
}

/* 链接样式优化 */
.prose a {
  font-weight: 600;
  color: #2563eb;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: all 0.3s ease;
}

.prose a:hover {
  color: #1d4ed8;
  border-bottom-color: #3b82f6;
}

/* 分隔线样式 */
.prose hr {
  margin: 2rem 0;
  border: none;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, #3b82f6 50%, transparent 100%);
}

/* 图片样式优化 */
.prose img {
  border-radius: 0.5rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  margin: 0 auto;
  max-width: 100%;
  height: auto;
}

/* 自定义滚动条样式 */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* 目录导航样式 */
.writing-mode-vertical-rl {
  writing-mode: vertical-rl;
}

.text-orientation-mixed {
  text-orientation: mixed;
}

/* 响应式优化 */
@media (max-width: 768px) {
  .prose h1 {
    font-size: 1.875rem;
  }
  
  .prose h2 {
    font-size: 1.5rem;
  }
  
  .prose h3 {
    font-size: 1.25rem;
  }
  
  .prose pre {
    padding: 1rem;
  }
  
  .prose th,
  .prose td {
    padding: 0.5rem 0.75rem;
  }
}
</style>